{% extends "website/base.html" %}

{% block titleblock %}Login{% endblock %}

{% block body %}

{% load addclass %}
<div class="container main-content mt-4" id="main-copy">
  <div class="row">
    <div class="col-lg-5 offset-lg-3 col-sm-12">
      <div class="card mt-3">
        <div class="card-body">
          <h1 class="card-title">Login</h1>
          <hr />
          {% include 'website/messages.html' %}
          {% if user.is_authenticated %}
          <div class="alert alert-info" role="alert">You are already logged in!</div>
          {% else %}
            {% if form.errors %}
            <div class="alert alert-danger" role="alert">Your username and password are incorrect. Please try again.</div>
            {% endif %}
          {% endif %}

          {% if not user.is_authenticated %}
          <form method="post" action=".">
            {% csrf_token %}

            <div class="form-group">
              <label for="id_username">Username:</label>
              {{ form.username | addclass:"form-control" }}
            </div>

            <div class="form-group">
              <label for="id_password">Password:</label>
              {{ form.password | addclass:"form-control" }}
            </div>

            <hr />
            <div class="row">
              <div class="col-lg-6 col-sm-12 text-center small"><a href="{% url 'password_reset' %}">Forgot Password?</a></div>
              <div class="col-lg-6 col-sm-12 text-center small"><a href="{% url 'register' %}">Create Account</a></div>
            </div>

            <hr />
            <div class="form-group">
              <input class="form-control btn btn-outline-secondary" type="submit" value="Login" />
              <input type="hidden" name="next" value="{{ next }}" />
            </div>
          </form>

          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %}
